function setCookie (c_name, value) {
  document.cookie = c_name + '=' + escape(value) + ';'
}

function getCookie (c_name) {
  var status = -1
  var c_start = -1
  var c_end = -1
  var cookie = document.cookie
  if (cookie.length > 0) {
    c_start = cookie.indexOf(c_name + '=')
    if (c_start > -1) {
      c_start = c_start + c_name.length + 1
      c_end = cookie.indexOf(';', c_start)
      if (c_end === -1) {
        c_end = cookie.length
      }
      return unescape(cookie.substring(c_start, c_end))
    }
  }
  return '-1'
}

function deleCookie (c_name) {
  document.cookie = c_name + '=' + escape('-1')
}

export function optionCookie (option, parameter) {
  if (option === 'set') {
    setCookie(parameter.name, parameter.value)
    return '1'
  } else if (option === 'get') {
    return getCookie(parameter)
  } else if (option === 'del') {
    deleCookie(parameter.name)
    return '1'
  }
}
